home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Workspace / Locus / Source / AppIconView.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  224 lines

  1.  
  2. /*
  3.     Copyright 1993  Jeremy Slade.
  4.  
  5.     You are free to use all or any parts of the Locus project
  6.     however you wish, just give credit where credit is due.
  7.     The author (Jeremy Slade) shall not be held responsible
  8.     for any damages that result out of use or misuse of any
  9.     part of this project.
  10.  
  11. */
  12.  
  13. /*
  14.     Project: Locus
  15.     
  16.     Class: AppIconView
  17.     
  18.     Description: See AppIconView.h
  19.  
  20.     Original Author: Jeremy Slade
  21.     
  22.     Revision History:
  23.         Created
  24.             V.101    JGS Tue Feb  2 18:50:26 GMT-0700 1993
  25.  
  26. */
  27.  
  28. #import "AppIconView.h"
  29.  
  30. #import "Globals.h"
  31.  
  32. #import <dpsclient/psops.h>
  33.  
  34.  
  35. @implementation AppIconView
  36.  
  37.  
  38. + initialize
  39. {
  40.     [self setVersion:AppIconView_VERSION];
  41.     return ( self );
  42. }
  43.  
  44.  
  45.  
  46. - init
  47. /*
  48.     Automatically sizes the view to 48x48, the size of the icons.
  49. */
  50. {
  51.     NXRect rect = { {8.0,8.0}, {48.0,48.0} };
  52.  
  53.     [self initFrame:&rect];
  54.     return ( self );
  55. }
  56.  
  57.  
  58.  
  59. - initFrame:(const NXRect *)frameRect
  60. {
  61.     [super initFrame:frameRect];
  62.     
  63.     isAttached = NO;
  64.     return ( self );
  65. }
  66.  
  67.  
  68.  
  69.  
  70. - free
  71. {
  72.     [self detachFromIcon];
  73.     if ( icon ) NX_FREE ( icon );    
  74.     return ( [super free] );
  75. }
  76.  
  77.  
  78.  
  79. - attachToIcon:theWindow
  80. {
  81.     // Attach to the window
  82.     if ( !isAttached && theWindow ) {
  83.         [[theWindow contentView] addSubview:self];
  84.         isAttached = YES;
  85.         [self display];
  86.         NXPing(); // Flush the display
  87.     }    
  88.     return ( self );
  89. }
  90.  
  91.  
  92.  
  93. - detachFromIcon
  94. {
  95.     if ( isAttached ) {
  96.         [self removeFromSuperview];
  97.         isAttached = NO;
  98.     }
  99.     return ( self );
  100. }
  101.  
  102.  
  103.  
  104.  
  105. - setImage:anImage
  106. {
  107.     image = anImage;
  108.     
  109.     if ( icon ) {
  110.         NX_FREE ( icon );
  111.         icon = NULL;
  112.     }
  113.     
  114.     [self display];    
  115.     NXPing(); // Flush the display
  116.     
  117.     return ( self );
  118. }
  119.  
  120.  
  121.  
  122. - setIcon:(const char *)imageName;
  123. {
  124.     if ( icon ) NX_FREE ( icon );
  125.     icon = NXCopyStringBuffer ( imageName );
  126.     image = [NXImage findImageNamed:imageName];
  127.     
  128.     [self display];
  129.     NXPing(); // Flush the display
  130.     
  131.     return ( self );
  132. }
  133.  
  134.  
  135.  
  136. - (const char *)icon
  137. {
  138.     return ( icon );
  139. }
  140.  
  141.  
  142.  
  143. - image
  144. {
  145.     return ( image );
  146. }
  147.  
  148.  
  149.  
  150. - drawSelf:(const NXRect *)rects :(int)count
  151. {
  152.     NXPoint    point = {0.0, 0.0};
  153.     NXRect rect = bounds;
  154.         
  155.     // draw the new image
  156.     [image composite:NX_SOVER toPoint:&point];
  157.  
  158.     return ( self );
  159. }
  160.  
  161.  
  162.  
  163. // -------------------------------------------------------------------------
  164. //   NXDraggingDestination Protocol - forward to folderController
  165. // -------------------------------------------------------------------------
  166.  
  167.  
  168. - setDraggingEnabled:(BOOL)flag
  169. {
  170.     if ( flag == YES ) {
  171.         [self registerForDraggedTypes:dragInTypes count:DRAGINTYPES];
  172.     } else {
  173.         [self unregisterDraggedTypes];
  174.     }
  175.     return ( self );
  176. }
  177.  
  178.  
  179.  
  180. - (NXDragOperation)draggingEntered:(id <NXDraggingInfo>)sender
  181. {
  182.     [folderController setDragDest:self];
  183.     return ( [folderController draggingEntered:sender] );
  184. }
  185.  
  186.  
  187.  
  188. - (NXDragOperation)draggingUpdated:(id <NXDraggingInfo>)sender
  189. {
  190.     return ( [folderController draggingUpdated:sender] );
  191. }
  192.  
  193.  
  194.  
  195. - draggingExited:(id <NXDraggingInfo>)sender
  196. {
  197.     return ( [folderController draggingExited:sender] );
  198. }
  199.  
  200.  
  201.  
  202. - (BOOL)prepareForDragOperation:(id <NXDraggingInfo>)sender
  203. {
  204.     return ( [folderController prepareForDragOperation:sender] );
  205. }
  206.  
  207.  
  208.  
  209. - (BOOL)performDragOperation:(id <NXDraggingInfo>)sender
  210. {
  211.     return ( [folderController performDragOperation:sender] );
  212. }
  213.  
  214.  
  215.  
  216. - concludeDragOperation:(id <NXDraggingInfo>)sender
  217. {
  218.     return ( [folderController concludeDragOperation:sender] );
  219. }
  220.  
  221.  
  222.  
  223. @end
  224.